//
//  KDNavNormalView.m
//
//  Created by HaoDong chen on 2019/6/4.
//  Copyright © 2019 dong rights reserved.
//

#import "HDNavNormalView.h"
#import "HDBaseDefine.h"
#import <Masonry/Masonry.h>

@implementation HDNavNormalView
@synthesize rightBtn1 = _rightBtn1;
@synthesize rightBtn2 = _rightBtn2;
@synthesize rightBtn3 = _rightBtn3;

@synthesize leftBtn1 = _leftBtn1;
@synthesize leftBtn2 = _leftBtn2;
@synthesize leftBtn3 = _leftBtn3;

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        HDButton *backBtn   = [HDButton new];
        [self addSubview:backBtn];
        _leftBtn = backBtn;
        
        _centerBtn = [HDButton new];
        [self addSubview:self.centerBtn];
        
        _rightBtn = [HDButton new];
        [self addSubview:self.rightBtn];
        [self.leftBtn setContentCompressionResistancePriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
        [self.leftBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(15);
            make.height.mas_equalTo(44);
            make.centerY.mas_equalTo(self).offset(HDSafeTopHeight/2);
            make.width.mas_equalTo(45);
        }];
        
        [self.centerBtn setContentCompressionResistancePriority:UILayoutPriorityDefaultLow forAxis:UILayoutConstraintAxisHorizontal];
        [self.centerBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.mas_equalTo(self).offset(HDSafeTopHeight/2);
            make.centerX.mas_equalTo(self);
            make.right.mas_lessThanOrEqualTo(self.rightBtn.mas_left);
            make.left.mas_greaterThanOrEqualTo(self.leftBtn.mas_right);
        }];
        [self.rightBtn setContentCompressionResistancePriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
        [self.rightBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(-15);
            make.centerY.mas_equalTo(self).offset(HDSafeTopHeight/2);
            make.height.mas_equalTo(44);
        }];
        
        self.backgroundColor = [UIColor whiteColor];
    }
    return self;
}
- (HDButton *)rightBtn1
{
    if (!_rightBtn1) {
        _rightBtn1 = [HDButton new];
    }
    [self addSubview:_rightBtn1];
    return _rightBtn1;
}
- (HDButton *)rightBtn2
{
    if (!_rightBtn2) {
        _rightBtn2 = [HDButton new];
    }
    [self addSubview:_rightBtn2];
    return _rightBtn2;
}
- (HDButton *)rightBtn3
{
    if (!_rightBtn3) {
        _rightBtn3 = [HDButton new];
    }
    [self addSubview:_rightBtn3];
    return _rightBtn3;
}

- (HDButton *)leftBtn1
{
    if (!_leftBtn1) {
        _leftBtn1 = [HDButton new];
    }
    [self addSubview:_leftBtn1];
    return _leftBtn1;
}
- (HDButton *)leftBtn2
{
    if (!_leftBtn2) {
        _leftBtn2 = [HDButton new];
    }
    [self addSubview:_leftBtn2];
    return _leftBtn2;
}
- (HDButton *)leftBtn3
{
    if (!_leftBtn3) {
        _leftBtn3 = [HDButton new];
    }
    [self addSubview:_leftBtn3];
    return _leftBtn3;
}

- (void)updateLeftBtnLeftGap:(CGFloat)leftGap {
    [self.leftBtn mas_updateConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(leftGap);
    }];
}

- (void)updateRightBtnRightGap:(CGFloat)rightGap {
    [self.rightBtn mas_updateConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-rightGap);
    }];
}

@end
